Skip to content

Conversation

icfaust
Copy link
Contributor

@icfaust icfaust commented Sep 23, 2025

Description

Scikit-learn does not yet support any classifiers for array API. As such, there are core functions like compute_class_weight which must be adapted locally for array API. This adds a private function _compute_class_weight for use in sklearnex classifier estimators in order to enable them for array API. It uses an initial check using get_namespace and replicates line by line the functionality of sklearn written using the array API standard if necessary.

This will be important for #2201 and #2209, as well as changes for KNeighborsClassifier.


Checklist:

Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

Copy link

codecov bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sklearnex/utils/class_weight.py 71.42% 6 Missing and 6 partials ⚠️
Flag Coverage Δ
azure 80.51% <69.04%> (-0.15%) ⬇️
github 73.19% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sklearnex/utils/class_weight.py 71.42% <71.42%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@icfaust
Copy link
Contributor Author

icfaust commented Sep 24, 2025

/intelci: run

@icfaust icfaust marked this pull request as ready for review September 24, 2025 22:24
Copy link
Contributor

@Vika-F Vika-F left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good, I just have a couple of questions.
Also check_class_weight should be changed to compute_class_weight in the description.

And just for the sake of general understanding it would be good to know why this functionality is implemented as a hidden function in case of array API?

@icfaust
Copy link
Contributor Author

icfaust commented Sep 30, 2025

@Vika-F you are absolutely right. I will change the title.

@icfaust icfaust changed the title [enh] add array API enabled check_class_weight function for use in classifier estimators [enh] add array API enabled compute_class_weight function for use in classifier estimators Sep 30, 2025
@icfaust
Copy link
Contributor Author

icfaust commented Sep 30, 2025

/intelci: run

@icfaust
Copy link
Contributor Author

icfaust commented Oct 1, 2025

/intelci: run

@icfaust
Copy link
Contributor Author

icfaust commented Oct 1, 2025

/intelci: run

@icfaust icfaust merged commit 754d32d into uxlfoundation:main Oct 1, 2025
31 checks passed
@icfaust icfaust deleted the dev/class_weight branch October 1, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants